from collections import OrderedDict

from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response

class PageNum(PageNumberPagination):
    # 开启分页
    page_size = 5

    page_size_query_param ='pagesize'

    # 最大一页多少条记录
    def get_paginated_response(self, data):

        return Response (OrderedDict([
            ('count', self.page.paginator.count),
            ('lists', data),
            ('page', self.page.number),
            ('pages', self.page.paginator.num_pages),
            ('pagesize', self.page.paginator.per_page)
        ]))
